import request from '@/utils/request'
import { AxiosPromise } from 'axios'

enum Api {
  list = '/notifyTemplate/list',
  add = '/notifyTemplate/add',
  edit = '/notifyTemplate/edit',
  delete = '/notifyTemplate/delete',
  batchDelete = '/notifyTemplate/batchDelete',
  changeStatus = '/notifyTemplate/changeStatus',
}

export const notifyTemplateList = (data): AxiosPromise<any> => {
  return request({
    url: Api.list,
    method: 'post',
    data,
  })
}
// 编辑、保存
export const notifyTemplateSave = (data: any) => {
  return request({
    url: data.id ? Api.edit : Api.add,
    method: 'post',
    data,
  })
}

// 删除
export const notifyTemplateDelete = (data: string) => {
  return request({
    url: Api.delete,
    method: 'post',
    data,
  })
}
// 批量删除
export const notifyTemplateBatchDelete = (data: (string | number)[]) => {
  return request({
    url: Api.batchDelete,
    method: 'post',
    data,
  })
}

// 状态修改
export function changeStatus(id: string | number, status: number) {
  const data = {
    id,
    status,
  }
  return request({
    url: Api.changeStatus,
    method: 'post',
    data,
  })
}
